<html>
<head>
    <meta charset="utf-8">
    <title>发布帖子 - 数媒贴吧</title>
    <link rel="stylesheet" href="/statics/css/index.css">
    <link rel="stylesheet" href="/statics/css/common.css">
    <link rel="stylesheet" href="/statics/css/form.css">
</head>
<body>
<?php require_once './Views/common/header.tpl.php';?>
<div class="box">
    <div class="left">
        <div class="user-form">
            <h3>发布帖子</h3>
            <form action="">
                <div class="user-from-item">
                    <label>分类</label>
                    <select name="cate_id">
                        <option value="0">请选择主题分类</option>
                        <?php foreach($cateList as $val):?>
                            <option value="<?php echo $val['id'];?>"><?php echo $val['title'];?></option>
                        <?php endforeach;?>
                    </select>
                </div>
                <div class="user-from-item">
                    <label>主题</label>
                    <input type="text" name="title">
                </div>
                <div class="user-from-item">
                    <label class="t">内容</label>
                    <textarea name="content" id="" cols="30" rows="10"></textarea>
                </div>
                <div class="error"></div>
                <div class="user-from-item">
                    <input type="submit" class="submit" value="发布"/>
                </div>
            </form>
        </div>
    </div>
    <?php require_once './Views/common/right.tpl.php'?>
</div>
<div class="clear"></div>
<?php require_once './Views/common/footer.tpl.php'?>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    jQuery(function() {
        jQuery('form').submit(function() {
            var params = jQuery('form').serialize();
            jQuery.post('/index.php?c=post&a=add', params, function(data) {
                if (data.status == 200) {
                    alert('发布成功');
                    window.location.href='/'
                } else if(data.status == 401) {
                    alert('用户尚未登录');
                    window.location.href='/index.php?c=user&a=login'
                } else {
                    jQuery('.error').html(data.message);
                }
            }, 'json');
            return false;
        });
    })
</script>
</body>
</html>